public class demo07 {
    public static void main(String[] args) {
        //定义一个变量来记录满足条件的个数
        int count = 0;
        //循环从1000-9999来筛选满足条件的数
        for (int i = 1000; i <= 9999; i++) {
            int ge = i % 10;
            int shi = i / 10 % 10;
            int bai = i / 100 % 10;
            int qian = i / 1000 % 10;
            if (ge + bai == shi + qian) {
                System.out.print(i + " ");
                count++;
                if (count % 5 == 0) {
                    System.out.println();
                }
            }
        }
        System.out.println("一共有" + count + "个");
    }
}